import request from '@/config/axios'

// 物料供应商关联 VO
export interface RelationshipVO {
  id: number // 关联编号
  productId: number // 产品编号
  supplierId: number // 供应商编号
}

// 物料供应商关联 API
export const RelationshipApi = {
  // 查询物料供应商关联分页
  getRelationshipPage: async (params: any) => {
    return await request.get({ url: `/erp/relationship/page`, params })
  },

  // 查询物料供应商关联详情
  getRelationship: async (id: number) => {
    return await request.get({ url: `/erp/relationship/get?id=` + id })
  },

  // 查询物料供应商关联详情
  getProductCategorySimpleBySupplie: async (id: number) => {
    return await request.get({ url: `/erp/relationship/getSupplie?id=` + id })
  },
  

  // 新增物料供应商关联
  createRelationship: async (data: RelationshipVO) => {
    return await request.post({ url: `/erp/relationship/create`, data })
  },

  // 修改物料供应商关联
  updateRelationship: async (data: RelationshipVO) => {
    return await request.put({ url: `/erp/relationship/update`, data })
  },

  // 删除物料供应商关联
  deleteRelationship: async (id: number) => {
    return await request.delete({ url: `/erp/relationship/delete?id=` + id })
  },

  // 导出物料供应商关联 Excel
  exportRelationship: async (params) => {
    return await request.download({ url: `/erp/relationship/export-excel`, params })
  },

// ==================== 子表（物料字典） ====================

  // 获得物料字典
  getProductById: async (id) => {
    return await request.get({ url: `/erp/relationship/product/get-by-id?id=` + id })
  },

// ==================== 子表（供应商管理） ====================

  // 获得供应商管理
  getSupplierById: async (id) => {
    return await request.get({ url: `/erp/relationship/supplier/get-by-id?id=` + id })
  },
}
